#include <iostream>
#include <vector>
using namespace std;

int t;
int h, a, H, A;

int main() {
    cin >> t;
    while (t--) {
        cin >> h >> a >> H >> A;
        int count = 0;
        int n = (H - a) / a * A;
        if (n == 0) cout << "-1";
        else cout << ((h - 1) / n) << endl;
    }
}
